import { post } from '@/utils/http'

enum API {
  // 注册接口地址
  REGISTER_API = '/api/register',
  // 登录接口地址
  LOGIN_API = '/api/login',
  // 验证接口地址
  VERIFY_API = '/user/verify',
  // 重置密码接口地址
  RESETPASSWORD_API = '/user/updatePasswordLogin',
  // 获取动态路由
  GETROUTES_API = '/api/getRoutes'
}
// 注册接口
export const registerAPI = (data: LoginForm) => {
  return post<LoginForm>(API.REGISTER_API, data)
}
// 登录接口
export const loginAPI = (account: number, password: string) => {
  return post<number>(API.LOGIN_API, { account, password })
}
// 忘记密码验证
export const verifyAPI = (data: LoginForm) => {
  return post<number>(API.VERIFY_API, data)
}
// 密码重置
export const resetPasswordAPI = (data: LoginForm) => {
  return post<void>(API.RESETPASSWORD_API, { newPassword: data.newPassword, id: data.id })
}
/** 获取动态路由 */
export const getRouterListAPI = (id: number) => {
  return post(API.GETROUTES_API, { id })
}
